/**
 * @tag models, home
 * Wraps backend report services.  Enables 
 * [Report.static.findAll retrieving],
 * [Report.static.update updating],
 * [Report.static.destroy destroying], and
 * [Report.static.create creating] reports.
 */
$.Model.extend('Bugstat.Models.Report',
/* @Static */
{
    /**
     * Retrieves reports data from your backend services.
     * @param {Object} params params that might refine your results.
     * @param {Function} success a callback function that returns wrapped report objects.
     * @param {Function} error a callback function for an error in the ajax request.
     */
    findById : function(id, success, error){
        $.ajax({
            url: 'reports/' + id + '.get',
            type: 'get',
            dataType: 'json',
            data: {},
            success: this.callback(['wrap',success]),
			error: error
        })
    }
},
/* @Prototype */
{
	fullName: '',
	
	init : function(attrs) {
		// this._super(attrs);
		
		this.fullName = (this.group ? (this.group + ': ') : '') + this.name;
	
		if ( !this.group )
		{
			this.group = 'Overview'
		}
	},
	
	fixTimestamps: function ()	
	{ 
		// first correct the timestamps - they are recorded as the daily
	    // midnights in UTC+0100, but Flot always displays dates in UTC
	    // so we have to add one hour to hit the midnights in the plot
	    for (var i = 0; i < this.report_data.length; ++i)
		{
			this.report_data[i][0] += 60 * 60 * 1000;
		}
	}
})